/**
*  Copyright 2009-2014 by WWW.KNET.CN  All rights reserved.
*/
package com.domain.service;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import com.domain.mapper.ISysNodeMapper;
import com.domain.model.SysNode;

/**
 * TODO(这里用一句话描述这个类的作用)
 * @author liujie
 * @date 2015年4月17日 下午1:25:05
 * 
 */
@Service(value="sysNodeService")
public class SysNodeService {
	@Resource
	private ISysNodeMapper sysNodeMapper;
	 public  void add(SysNode node){
		    String maxCode=sysNodeMapper.getMaxCode(node.getParentsNodeId());
		    if (StringUtils.isEmpty(maxCode)) {
				maxCode=node.getParentsNodeId()+"01";
			}
		    if (node.getParentsNodeId().equals("0")) {
				node.setIsHasSonNode(1);
			}
		    node.setNodeCode(maxCode);
		
		 sysNodeMapper.add(node);
	 }
		public SysNode getNodeByCode(String nodeCode){
			return sysNodeMapper.getNodeByCode(nodeCode);
		}

	  public  void update(SysNode node){
		  SysNode obj=sysNodeMapper.get(node.getId()); 
		  if (null != obj) {
			node.setIsHasSonNode(obj.getIsHasSonNode());
			node.setSque(obj.getSque());
		  }
		  sysNodeMapper.update(node);
	  }

	  public  void  deleteById(Long paramLong){
		  sysNodeMapper.deleteById(paramLong);
	  }
	  public int isUse(String nodeCode){
		  return sysNodeMapper.isUse(nodeCode);
	  }

	  public  SysNode get(Long paramLong){
		  return sysNodeMapper.get(paramLong);
	  }


	  public  List<Map<String, Object>> getListPage(Map<String, Object> paramMap){
		  return sysNodeMapper.getListPage(paramMap);
	  }

	  public  Long getRows(Map<String, Object> paramMap){
		  return sysNodeMapper.getRows(paramMap);
	  }
	  
}
